
//
//  CellForPhotoPlayer.m
//  ProjectA
//
//  Created by dllo on 16/3/4.
//  Copyright © 2016年 刘旺辉. All rights reserved.
//

#import "CellForPhotoPlayer.h"
#import "ModelForDestinationPhoto.h"
#import <UIImageView+WebCache.h>
#import "NSString+HeightLabel.h"
@interface CellForPhotoPlayer ()
@property (nonatomic, strong) UIView *view1;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *labelForText;
@property (nonatomic, strong) UILabel *labelForlocal_time;
@end

@implementation CellForPhotoPlayer
- (void)dealloc {
    [_view1 release];
    [_imageView release];
    [_labelForText release];
    [_labelForlocal_time release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        self.imageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imageView];
        [_imageView release];
        
        self.labelForText = [[UILabel alloc] init];
        [self.contentView addSubview:self.labelForText];
        [_labelForText release];
        
        self.view1 = [[UIView alloc] init];
        [self.labelForText addSubview:self.view1];
        [_view1 release];
        [[self.view1 superview] bringSubviewToFront:self.view1];
        self.view1.backgroundColor = [UIColor blackColor];
        self.view1.alpha = 0.75;
        
        
        self.labelForlocal_time = [[UILabel alloc] init];
        [self.contentView addSubview:self.labelForlocal_time];
        [_labelForlocal_time release];
    }
    return self;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.labelForText.numberOfLines = 0;
    self.labelForText.textColor = [UIColor whiteColor];
    
    self.labelForlocal_time.frame = CGRectMake(15, self.bounds.size.height - 20 - 10, self.bounds.size.width - 30, 20);
    self.labelForlocal_time.font = [UIFont systemFontOfSize:13];
    self.labelForlocal_time.textColor = [UIColor whiteColor];
    
    self.view1.frame = self.labelForText.bounds;
    
}
- (void)passData:(ModelForDestinationPhoto *)model {
    
    CGFloat height = [NSString heightForImageSetHeight:[[model.photo_info objectForKey:@"h"] floatValue] setWidth:[[model.photo_info objectForKey:@"w"] floatValue] getWidth:self.bounds.size.width - 10];
    self.imageView.frame = CGRectMake(5, 20, self.bounds.size.width - 10, height);

    
    CGFloat h = [NSString heightForLabel:model.text withWidth:self.bounds.size.width - 30 withEdge:0 withFontOfSize:13];
    self.labelForText.frame = CGRectMake(15, self.bounds.size.height - 20 - 10 - h - 10, self.bounds.size.width - 30, h);
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.photo_webtrip]];
    
    self.labelForText.text = model.text;
    self.labelForlocal_time.text = model.local_time;
 
}
@end
